import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/public.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
import axios from 'axios'
// 导入时间插件
import dayjs from 'dayjs'
// 图片预览
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
// 导入echarts
import echarts from 'echarts'

// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

// 导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css'
Vue.prototype.$echarts = echarts
Vue.prototype.dayjs = dayjs // for bubble theme

// 配置请求的根路径
Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

axios.interceptors.request.use(config => {
  // 为请求头对象，添加token验证的authorization 字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 最后必须return config
  return config
})
Vue.config.productionTip = false
// 注册第三方组件
Vue.component('tree-table', TreeTable)
// 全局注册富文本编辑器
Vue.use(VueQuillEditor)
// 全局注册图片预览
Vue.use(Viewer)
Viewer.setDefaults({
  Options: { inline: true, button: true, navbar: true, title: true, toolbar: true, tooltip: true, movable: true, zoomable: true, rotatable: true, scalable: true, transition: true, fullscreen: true, keyboard: true, url: 'data-source' }
})

// 全局过滤器
Vue.filter('DateFormat', function (timeVal) {
  return dayjs(timeVal).format('YYYY-MM-DD hh:mm:ss')
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
